package task11;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import task08.Student;


/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/27 8:36
 * @description:
 */
public class Task11 {

  public static void main(String[] args) {
    HashMap<String,Student> studentHashMap=new HashMap<String,Student>();
    Student student1=new Student("Mary",18);
    Student student2=new Student("Tom",19);
    Student student3=new Student("Jack",17);
    studentHashMap.put("s1",student1);
    studentHashMap.put("s2",student2);
    studentHashMap.put("s3",student3);

    Iterator iterator=studentHashMap.keySet().iterator();
    while(iterator.hasNext()){
      String key=(String) iterator.next();
      Student value=studentHashMap.get(key);
      System.out.println(key+":"+value);
    }
    System.out.println();

    Iterator entryIterator=studentHashMap.entrySet().iterator();
    while (entryIterator.hasNext()){
      Map.Entry<String,Student>entry= (Entry<String,Student>) entryIterator.next();
      String key=entry.getKey();
      Student value=entry.getValue();
      System.out.println(key+"--"+value);
    }
  }
}